import { defineStore } from "pinia";

// 第一种语法
export const menuStore = defineStore("menu", {
  state: () => ({
    role: "",
    menu: [
      {
        title: "房子",
        name: "home",
        path: "/home",
        icon: "Home",
        children: [
          {
            title: "主页",
            name: "homeIndex",
            path: "homeIndex",
            icon: "Bed",
          },
          {
            title: "关于",
            name: "homeAbout",
            path: "homeAbout",
            icon: "GitCommit",
          },
        ],
      },

      {
        title: "商品管理",
        name: "goods",
        path: "/goods",
        icon: "LogoDocker",
        children: [
          {
            title: "商品列表",
            name: "list",
            path: "list",
            icon: "LogoHtml5",
          },
          {
            title: "商店",
            name: "shop",
            path: "shop",
            icon: "LogoLaravel",
          },
        ],
      },
    ],
    history: [],
  }),
  getters: {
    // doubleCount: (state) => state.count * 2,
  },
  actions: {
    // increment() {
    //   this.count++;
    // },
  },
});

export async function asyncRenderIcon(icon) {
  const { [icon]: iconComp } = await import("@vicons/ionicons5");
  return () => h(NIcon, null, { default: () => h(iconComp) });
}

// 第二种语法
// export const useCounterStore = defineStore('counter', () => {
//   const count = ref(0)
//   const name = ref('Eduardo')
//   const doubleCount = computed(() => count.value * 2)
//   function increment() {
//     count.value++
//   }

//   return { count, name, doubleCount, increment }
// })
